﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace a23_ContextMenu
{
    public class MyLabel: Label
    {
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            base.OnContextMenuOpening(e);

            var buttonMenu = new ContextMenu();
            var mia = new MenuItem { Header = "on 1" };
            var mib = new MenuItem { Header = "on 2" };
            var mic = new MenuItem { Header = "on 3" };
            buttonMenu.Items.Add(mia);
            buttonMenu.Items.Add(mib);
            buttonMenu.Items.Add(mic);

            var fe = e.Source as FrameworkElement;
            fe.ContextMenu = buttonMenu;
        }
    }
}
